<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>佐心，教家长做父母</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="assets/css/amazeui.min.css">
    <link rel="stylesheet" href="assets/css/style.css?v=2.3">
    <link rel="stylesheet" href="assets/css/index.css?v=2.3">
    <script>
    	    /** 
     * 返回前一页（或关闭本页面） 
     * <li>如果没有前一页历史，则直接关闭当前页面</li> 
     */  
    function goBack(){  
        if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)){ // IE  
            if(history.length > 0){  
                window.history.go( -1 );  
            }else{  
                location.href="${ctx}/index.jsp";
            }  
        }else{ //非IE浏览器  
            if (navigator.userAgent.indexOf('Firefox') >= 0 ||  
                navigator.userAgent.indexOf('Opera') >= 0 ||  
                navigator.userAgent.indexOf('Safari') >= 0 ||  
                navigator.userAgent.indexOf('Chrome') >= 0 ||  
                navigator.userAgent.indexOf('WebKit') >= 0){  
      
                if(window.history.length > 1){  
                    window.history.go( -1 );  
                }else{  
                    location.href="${ctx}/index.jsp";
                }  
            }else{ //未知的浏览器  
                window.history.go( -1 );  
            }  
        }  
    }  
    </script>
</head>
<body class="bg-white">
<header data-am-widget="header" class="am-header am-header-default am-header-fixed am-border-bottom">
    <div class="am-header-left am-header-nav">
        <a  onclick="goBack();"  >
            <i class="icon_8"></i>
        </a>
    </div>
    <h1 class="am-header-title">
        我的提问
    </h1>

</header>
<section class="am-padding-bottom-sm" id="amz-main" data-tag="css-nav">
    <div class="report_list" id="question_list">

    </div>
     <!--隐藏音频-->
    <div class="am-hide">
        <audio src=""  id="audio">亲 您的浏览器不支持html5的audio标签</audio>
    </div>
</section>


<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">提问删除</div>
        <div class="am-modal-bd">
            你，确定要删除这条记录吗？
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>确定</span>
        </div>
    </div>
</div>

<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script>
    $(function () {
		var myFreeAsksList=$.ajax({url:"getMyFreeAsks",async:false});
        var myFreeAsksJson=JSON.parse(myFreeAsksList.responseText);
        var html="";
        if(myFreeAsksJson.resultCode=="0"){
        	for(var i=0;i<myFreeAsksJson.freeAskList.length;i++){
         html+="<div class='report_item bg-gray am-margin-left-sm am-margin-right-sm am-margin-top-sm'>";
         html+="    <div class='am-g   am-padding-top-sm border-1'>";
         html+="        <div class=' am-u-sm-12 am-list-main font-color-13 box'>";
         html+="           <i class='icon_12'></i>";
         html+="          <div class='width-50px'>";
         html+="               <div class='icon_71_1'></div>";
         html+="          </div>";
         html+="          <div class='box-1 prelative'>";
         html+="              <div class='am-list-item-hd font-color-13 padding-top-10'>";
         html+="咨询领域："+myFreeAsksJson.freeAskList[i].direction;
         html+="              </div>";
         html+="              <i class='icon_43' data-id='"+myFreeAsksJson.freeAskList[i].id+"'></i>";
         html+="          </div>";
         html+="     </div>";
         html+="      <div class='am-u-sm-12 font-14 am-margin-top-sm'>";
         if(myFreeAsksJson.freeAskList[i].type==0){
         html+=myFreeAsksJson.freeAskList[i].question;
         }else{
 			html+="<div class='btn_18 voice' >";
 			html+="<input type='hidden' value='"+myFreeAsksJson.freeAskList[i].question+"'>";
            html+="<i class='icon_711 '></i><span></span>";
            html+="</div>";
         }
         html+="      </div>";
         html+="      <div class='am-u-sm-7 am-margin-top-xs'>";
         html+="         <div class='border-tops font-color-15  am-padding-top-sm am-padding-bottom-sm prelative padding-right-20'>";
         html+=myFreeAsksJson.freeAskList[i].askTimeStr;
         html+="         </div>";
         html+="     </div>";
         html+="     <div class='am-u-sm-5 am-margin-top-xs'>";
         html+="        <div class='border-tops font-color-12 am-text-right am-padding-top-sm am-padding-bottom-sm prelative padding-right-20'>";
         if(myFreeAsksJson.freeAskList[i].status==0){
         	 html+="   <span class='font-color-13'>未答</span>";
         }else{
         html+="           <a href='gotoMyAskAnswer?askId="+myFreeAsksJson.freeAskList[i].id+"'><i class='icon_120'></i><span class='font-color-17'>已答</span></a>";
         }
         html+="        </div>";
         html+="    </div>";
         html+="</div>";
         html+=" </div>";
        	}
        }
		$("#question_list").html(html);
		
        $(function() {
            $('#question_list').find('.icon_43').on('click', function() {
                        $('#my-confirm').modal({
                            relatedTarget: this,
                            onConfirm: function(options) {
                                var $delete = $(this.relatedTarget);
                                var deleteId=$delete.data('id');
                                location.href="deleteFreeAsk?deleteId="+deleteId;
                            },
                            onCancel: function() {
                            }
                        });
                    });
        });
        $(".report_item .voice").on("click",function(){
            var audio = document.getElementById("audio");
            audio.src=$(this).find("input").val(); 
            
            var eventTester = function(e){
                audio.addEventListener(e,function(){
                    $voices.removeClass("cur");
                },false);
            };
            eventTester("ended");
            
            
          var $voices= $(this).find(".icon_711");
            $(".report_item .voice").find(".icon_711").remove("cur");
            if($voices.hasClass("cur")){
                $voices.removeClass("cur");
                audio.pause();
            }else{
                $voices.addClass("cur");

                audio.play();
            }

        });

    });
</script>
</body>
</html>